<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

<html>
<head>
  <link href="<s:url value="/resources"/>/css/style_new.css" rel="stylesheet" type="text/css" />
<link href="<s:url value="/resources"/>/css/main_new.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.min.css" />

   
<link rel="stylesheet" type="text/css" media="screen"
	href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen"
	href="<s:url value="/resources"/>/css/ui.multiselect.css" />
<script type="text/javascript"
	src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript"
	src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script>
<script type="text/javascript"
	src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script>
<script type="text/javascript"
	src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
<script type="text/javascript"
	src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
<style>
html,body {
	margin: 0;
	padding: 0;
	font-size: 85%;
}
</style>

</head>

<script type="text/javascript">  
    var temp_tab_id = "";  

    $(function(){
    $("#chax").button();
    $("#tib").button();
    $("#daoc").button();  
	 $("#daoc").hide(); 
    $("#reset").button();
    loadTab();
    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);  
    $("#myTab").jqGrid('hideCol',["chumdwmc"]); 
    
 });
 
 function loadChildTab(subgrid_id,row_id){
 //alert(subgrid_id);
 //alert(row_id);
 var subgrid_table_id, pager_id;
		subgrid_table_id = subgrid_id+"_t";
		//alert(temp_tab_id);
		if(temp_tab_id!=subgrid_id){
		   $("#"+temp_tab_id).hide();
		}		
		temp_tab_id = subgrid_id;		
		//alert(subgrid_table_id);
		pager_id = "p_"+subgrid_table_id;
		$("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
		jQuery("#"+subgrid_table_id).jqGrid({
			url:'<s:url value="/"/>/gpjy/findYdxxByBdh?bdbh='+row_id,
			datatype: 'json',
    mtype: 'post',         
   	colNames:['操作','应单人','[收货/发货]单位名称','应单数量','应单日期','买卖类型'],
   	colModel:[ 
   	    {name:'Verify',index:'id',width:60,align:"center",sortable:false},
   		{name:'yingdddwname',index:'yingdddwname', width:200 },
   		{name:'shdwmc',index:'shdwmc', width:200 },
   		{name:'yingdsl',index:'yingdsl', width:60 },
   		{name:'yingdsj',index:'yingdsj', width:180},	
   		{name:'maimlx',index:'maimlx', width:80, hidden:true}	
   	],
   
    jsonReader: {
           repeatitems : false, 
           id: 'yingdbm'
         },    	
   	rowNum:5,
   	width : 900,
   	rowList:[5,10,15],     	
   	pager: '#pager14',   	
   	rownumbers: true,   	 
    viewrecords: true,
    multiselect: true,
    sortorder: 'desc', 
	gridComplete:function()
	{ //在此事件中循环为每一行添加修改和删除链接 
		var ids=jQuery("#"+subgrid_table_id).jqGrid('getDataIDs'); 
		for(var j=0; j<ids.length; j++)
		{ 
			var id=ids[j]; 
			var model = jQuery("#"+subgrid_table_id).jqGrid('getRowData', id); 
			
			if(model.maimlx=="6")
			{
			verify ="<a href='#' style='color:#f60' onclick='Verify6("+ id +")'>查看</a>"; //这里的onclick就是调用了上面的javascript函数 Modify(id) 
			}else
			{
			verify ="<a href='#' style='color:#f60' onclick='Verify5("+ id +")'>查看</a>";
			}
			jQuery("#"+subgrid_table_id).jqGrid('setRowData',ids[j], { Verify: verify }); 
		} 
	} 
		});
		jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false})
 
 }
 
 function loadTab(){  
    $("#myTab").jqGrid({      
    url:'<s:url value="/"/>/gpjy/findXzcjlist?index=1',   
    datatype: 'json',
    mtype: 'post',         
   	colNames:['报单号','[收货/发货]单位名称','煤种','品种','价格','报单数量','应单数量','剩余数量','报单日期','买卖类型','报单状态'],
   	colModel:[   	      		
   		{name:'baodbm',index:'baodbm', width:120},
   		{name:'sfhdwmc',index:'sfhdwmc', width:200},
   		{name:'meizmc',index:'meizmc', width:80 },	
   		{name:'pinzmc',index:'pinzmc', width:80 },	
   		{name:'danj',index:'danj', width:60 },
   		{name:'shul',index:'shul', width:60 },
   		{name:'ydsl',index:'ydsl', width:60 },
   		{name:'shengysl',index:'shengysl', width:60 },
   		{name:'baodsj',index:'baodsj', width:80},   		
   		{name:'maimlxmc',index:'maimlxmc', width:60 },
   		{name:'danjztmc',index:'danjztmc', width:80}		
   	],
   
    jsonReader: {
           repeatitems : false, 
           id: 'baodbm'
         },  
    width : 1200,
   	rowNum:10,
   	rowList:[10,20,30],     	
   	pager: '#pager13',   	
   	rownumbers: true,   	 
    viewrecords: true,
    //multiselect: true,
    subGrid: true,    
    sortorder: 'desc',  
	caption: "报单列表",
	subGridRowExpanded:	function(subgrid_id, row_id) {
	loadChildTab(subgrid_id,row_id);	
   }
  });
  $("#myTab").jqGrid('setGridHeight','280px');
  }

// 查询
function search(){ 
  //alert("aaa");  
  var formdata = $("#form1").serialize();  
  $("#myTab").jqGrid('setGridParam',{url:'htcxJqgrid.action?'+formdata+'&index=3',mtype:'post',page:1}).trigger("reloadGrid"); 
}

function openwindow(url){
    var sheight = screen.height-70;
    var swidth = screen.width-10;
   var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
    var result=window.showModalDialog(url,window,winoption);
    //alert(result);
    if(result ==1){
     reloadcjxx();
      }
    return result;  
}

function reloadcjxx(){
   window.location.href="<s:url value="/"/>/gpjy/xzcjlist";
	}

	function submitRow() {
		var s = $("#" + temp_tab_id + "_t").jqGrid('getGridParam', 'selarrrow');
		//alert(s);
		if (s == ""||s== undefined) {
					alert("请先选择应单记录，再点击选择成交！");
					return;
				}
		openwindow('<s:url value="/"/>/gpjy/findCjxxInfo?ydbh=' + s);
	}

	function Verify6(id) { //单击修改链接的操作 
		//alert(id);
		openwindow('<s:url value="/"/>/gpjy/gpydMsryd?yingdbh='+id+'&lx=2' );

	}
	function Verify5(id) { //单击修改链接的操作 
		//alert(id);
		openwindow('<s:url value="/"/>/gpjy/gpydMsryd?yingdbh='+id+'&lx=2' );

	}

	//重置
	function resetSearch() {
		$('#list_search  input[type=text]').val('');
		$('#list_search select').val('-1');
	}

	function dc_excel() {
		form1.action = "/htgl/jytj_excel.action?index=0";
		form1.method = "post";
		form1.submit();
	}

	
</script>
<body>
	<div class="container">
  <div class="containerbox">
    <div class="btn-bar"> 
    <a href="#" class="btn" onclick= "submitRow();"><img src="<s:url value="/resources"/>/img/ico_23.png" /><span>选择成交</span></a> 
    
    </div>
    <div class="search mt10" id="list_search">
    <form id="form1" method="post">
    <table width="90%" border="0" cellspacing="0" cellpadding="0" class="search-table">
  <tr>
    <td align="left" valign="middle" class="search-table-300"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">发货单位</td>
    <td align="left"><input name="aa" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
    <td align="left" valign="middle" class="search-table-300"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">煤种</td>
    <td align="left"><select name="bb" class="form-textbox" style="width: 200px;">
      <option value="-1" selected>==请选择==</option>
                   <c:forEach var="mz" items="${meiz}">
                   <option value="${mz.diccode}">
                   ${mz.dicname}
                   </option>
                   </c:forEach>
                 </select></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">品种</td>
    <td align="left"><select name="cc" class="form-textbox" style="width: 200px;">
      <option value="-1" selected>==请选择==</option>
                   <c:forEach var="pz" items="${pinz}">
                   <option value="${pz.diccode}">
                   ${pz.dicname}
                   </option>
                   </c:forEach>
                 </select></td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">隶属行业</td>
    <td align="left"><select name="dd" class="form-textbox" style="width: 200px;">
       <option value="-1" selected>==请选择==</option>
                   <c:forEach var="hy" items="${hangy}">
                   <option value="${hy.diccode}">
                   ${hy.dicname}
                   </option>
                   </c:forEach>
    </select></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">发站（局）</td>
    <td align="left"><input name="ee" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">到站（局）</td>
    <td align="left"><input name="ff" type="text" class="form-textbox" style="width: 200px;" /></td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">价格</td>
    <td align="left"><input name="gg" type="text" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" />--
    <input name="hh" type="text" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');" /></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">数量</td>
    <td align="left"><input name="ii" type="text" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');"/>--
    <input name="jj" type="text" class="form-textbox" style="width: 93px;" onKeyUp="this.value=this.value.replace(/\D/g,'');"/></td>
  </tr>
</table></td>
    <td align="left" valign="middle"><table border="0" cellspacing="0" cellpadding="0" class="search-table-300">
  <tr>
    <td align="right" class="pr10 search-table-70">报单日期</td>
    <td align="left"><input name="kk" type="text" class="form-textbox" style="width: 93px;"  id="datepicker"/>--
    <input name="ll" type="text" class="form-textbox" style="width: 93px;"  id="datepicker1"/></td>
  </tr>
</table></td>
  </tr>
   <tr>
    <td align="left" valign="middle" colspan="3"><table border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td align="right" class="pr10 search-table-70">&nbsp;</td>
    <td align="left"><input name="" type="button" class="form-button-query form-button" value="查询" onclick="search();"/>
    <input name="" type="button" class="form-button-reset form-button" value="重置"  onclick="resetSearch();"/></td>
  </tr>
</table></td>
  </tr>
    </table>
</form></div>
			
   		<table id="myTab" class="scroll" cellpadding="0" cellspacing="0"></table>
		<div id="pager13" class="scroll"></div>
		<div id="pager14" class="scroll"></div>
		<div id="message" class="scroll"></div>
		<div id="dialog-confirm1" title="是否确认成交？"></div>
		<div id="jinggao" title="警告:请选择一条合同"></div>
    
  </div>
</div> 
	
	
</body>
</html>
